﻿@{
    ViewBag.Title = "Edit Item";
    ViewBag.ManageItemsActive = "active";
}
@if (TempData["Error"] != null)
{
    <div class="alert alert-error">
        @TempData["Error"]
    </div>
}

@if (TempData["Success"] != null)
{
    <div class="alert alert-success">
        @TempData["Success"]
    </div>
}
<h2>Edit @Model.item.Name</h2>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span6 well">

            <form class="form-horizontal" method="POST" action="~/ManageItems/EditTheItem">
                <div class="control-group" hidden="hidden">
                    <label class="control-label" for="id">Id</label>
                    <div class="controls">
                        <input type="text" name="id" value="@Model.item.Id"/>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="name">Name</label>
                    <div class="controls">
                        <input type="text" name="name" value="@Model.item.Name" pattern="[A-Za-z ]{1,20}" title="Only letters, 20 or less" required />
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="Oprice">Original Price</label>
                    <div class="controls">
                        <input type="text" name="Oprice" value="@Model.item.OriginalPrice" pattern="\d+(\.\d{2})?" title="0.00 format" required />
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="percentDiscount">Percent Discount</label>
                    <div class="controls">

                        <input type="text" name="percentDiscount" value="@Model.percent" pattern="\d{1,3}" title="Numbers only three digits or less (ex. 100, 85, 31)" required />
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="endTime">Ending Time</label>
                    <div class="controls">
                        <input type="text" name="endTime" value="@Model.item.EndTime" pattern="\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}\:\d{2}(\:\d{2})? (AM|PM)" title="DD/MM/YYYY HH:MM PM/AM" required />
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="description">Description</label>
                    <div class="controls">
                        <input type="text" name="description" value="@Model.item.Description"  pattern=".{1,100}" title="Description 100 characters or less" required />
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="photo">Photo URL</label>
                    <div class="controls">
                        <input type="text" name="photo" value="@Model.item.Photo"/>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" hidden="hidden" for="category">Category</label>
                    <div class="controls">
                        <select name="category" id="category">
                            <option selected="selected">Select a Category</option>
                            @foreach (var category in Model.categories)
                            {
                                if (category.Name.Equals(Model.item.CategoryObj.Name))
                                {
                                <option value="@category.Name" selected="selected">@category.Name</option>
                                }
                                else
                                {
                                <option value="@category.Name">@category.Name</option>
                                }

                            }
                        </select>
                    </div>
                    <input type="submit" class="btn btn-primary" value="Save" />
                </div>
            </form>
        </div>
    </div>
</div>
